cmake_minimum_required(VERSION 3.16)

project(cap-audio VERSION 1.0.0 LANGUAGES CXX)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# 查找Qt6组件 - 只保留Core和Multimedia
find_package(Qt6 REQUIRED COMPONENTS Core Multimedia)

# 设置源文件
set(SOURCES
    main.cpp
    audiocaptureservice.cpp
    config_manager.cpp
    audiocapture.cpp
    wasapi_loopback_capture_simple.cpp
    audiotransmitter.cpp
)

set(HEADERS
    config.h
    audiocaptureservice.h
    config_manager.h
    audiocapture.h
    wasapi_loopback_capture_simple.h
    audiotransmitter.h
)

# 创建主程序
qt_add_executable(cap-audio
    ${SOURCES}
    ${HEADERS}
)

# 链接Qt库 - 只链接Core和Multimedia
target_link_libraries(cap-audio PRIVATE
    Qt6::Core
    Qt6::Multimedia
)

# 设置包含目录
target_include_directories(cap-audio PRIVATE
    ${CMAKE_CURRENT_SOURCE_DIR}
)

# 启用Qt的MOC和RCC - 移除UIC
set_target_properties(cap-audio PROPERTIES
    AUTOMOC ON
    AUTORCC ON
)

# 在Windows上设置为Windows子系统，不显示控制台窗口
if(WIN32)
    set_target_properties(cap-audio PROPERTIES
        WIN32_EXECUTABLE TRUE
    )
endif()